<?php 
//遍历新闻表展示
  include_once("./com.php");
 $rem="select *from news";

$rs=mysql_query($sql);
$info=[];
$totalRows=mysql_num_rows($rs);
$pageRows=4;
$totalPage=ceil($totalRows / $pageRows);
$page=isset($_GET['page'])?$_GET['page']:1;
if ($page<=0||$page>$totalPage||!is_numeric($page)) {
  $page=1;
}
//5.处理limit查询的第一个参数，分页计算公式
$limitstart=$pageRows * ($page-1);
//6.组装sql语句
$sql="SELECT * FROM tk_admin order by admin_id desc limit {$limitstart},{$pageRows}";
//7.获取分页数据
$re=mysql_query($sql);
$info=[];
if(mysql_num_rows($re)>0){
  while($arr=mysql_fetch_assoc($re)){
    $info[]=$arr;
  }
}

 
  $ser=mysql_query($rem);
  while($res=mysql_fetch_assoc($ser)){
    $tye[]=$res;
  };

 ?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>商品管理</title>
<base target="_self">
<link rel="stylesheet" type="text/css" href="skin/css/base.css" />
<link rel="stylesheet" type="text/css" href="skin/css/main.css" />
</head>
<style type="text/css">
  .new{
    width:100px;
    white-space:nowrap;
    text-overflow:ellipsis;
    overflow:hidden;
  }
</style>
<body leftmargin="8" topmargin='8'>
<table width="98%" align="center" border="0" cellpadding="3" cellspacing="1" bgcolor="#CBD8AC" style="margin-bottom:8px;margin-top:8px;">
  <tr>
    <td background="skin/images/frame/wbg.gif" bgcolor="#EEF4EA" class='title' colspan="2"><span><img src='skin/images/frame/arr3.gif' style='margin-right:10px;'>产品列表</span></td>
  </tr>
    <tr bgcolor="#FFFFFF">
       <td colspan="2">
        <table width="98%" border="0" cellpadding="2" cellspacing="1" bgcolor="#CFCFCF" align="center" style="margin-top:8px">
        <tr align="center" bgcolor="#FBFCE2" height="25">
          <th>ID</th>
          <th>新闻标题</th>
          <th>新闻图片</th>
          <th>新闻内容</th>
          <th>新闻作者</th>
          <th>新闻时间</th>
          <th>浏览次数</th>
          <th>操作</th>
        </tr>
        <?php foreach ($tye as $value) { ?>
          <tr align='center' bgcolor="#FFFFFF" height="26" align="center" onMouseMove="javascript:this.bgColor='#FCFDEE';" onMouseOut="javascript:this.bgColor='#FFFFFF';">
            
          <td width="10%"><?= $value['nid']?></td>
           <td width="10%"><?= $value['ntitle'] ?></td>
          <td width="10%">
          	<?php   $er=explode("-",$value['nimg']);
          	foreach ($er as $vo) {?>
          		<img src="../uploads1/<?= $vo ?>" width="20px">
          <?php	}?>
          </td>
          <td width="10%"><div class="new"><?= $value['ndescp'] ?></div></td>
          <td width="10%"><?= $value['nname']?></td>
          <td width="10%"><?= $value['ntime']?></td>
          <td width="10%"><?= $value['number']+1?></td>
          <td width="10%">
         <a href="news_edit.php?nid=<?= $value['nid']?>"><img src='./skin/images/frame/trun.gif' title="编辑" alt="编辑" onClick="QuickEdit(179, event, this);" style='cursor:pointer' border='0' width='16' height='16' /></a>

         <a href="news_del.php?nid=<?= $value['nid']?>"><img src='./skin/images/frame/gtk-del.png' title="删除" alt="删除" onClick="editArc(179);" style='cursor:pointer' border='0' width='16' height='16' /></a>        
         </td> 
        </tr>
        <?php }?>
        </table>

<tr align="right" bgcolor="#F9FCEF">
        <td height="36" colspan="10" align="center">
        <div class="pagelistbox" style="font-size: 18px;">
          <span>共<?php echo $totalpage;?> 1页/<?php echo $totalRows;?>条记录</span>
          <span class="indexpage">
            <a href="?page=1">首页</a>
            <a class="prevPage" href="?page=<?php echo $page-1?>">上页</a>
          </span>

            <?php for($i=1;$i<= $totalpage;$i++):?>
              <?php if($i ==$page ):?>
              <strong><?php echo $i;?></strong>

              <?php else:?>
              <a href="?page=<?php echo $i;?>"><?php echo $i;?></a>

            <?php endif;?>
            <?php endfor;?> 
              <a class="nextpage" href="?page=<?php echo $page+1;?>">下页</a>
              <a class="endpage" href="?page=<?php echo $totalPage;?>">末页</a>
        </div>
      </td>
      </tr>

    </td>
  </tr>
  </tr>
</table>
</body>
</html>